package longrise.phone.com.bjjt_henan.myaccident;

import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.longrise.LEAP.Base.Objects.EntityBean;
import com.longrise.android.FormParameter;
import com.longrise.android.LFView;

import longrise.phone.com.bjjt_henan.R;
import longrise.phone.com.bjjt_henan.Utils.CommontUtils;

/**
 * 理赔信息界面
 */
public class PayInfoView extends LFView {

    private Context mContext;

    private View mView;

    private EntityBean[] baseBean;

    public PayInfoView(Context context, EntityBean[] bean) {
        super(context);
        this.mContext = context;
        this.baseBean = bean;
    }

    @Override
    public FormParameter getFormParameter() {
        FormParameter form = new FormParameter();
        form.setShowtitle(false);
        return form;
    }

    @Override
    public View getView() {
        return mView;
    }

    @Override
    public void init() {
        if (null == mContext) {
            return;
        }
        mView = LayoutInflater.from(mContext).inflate(R.layout.view_payinfo, null);
        if (null == mView) {
            return;
        }
        //标题栏
        TextView titleTV = (TextView) mView.findViewById(R.id.tv_title);
        titleTV.setText(R.string.pay_info);
        mView.findViewById(R.id.hn_btn_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                closeForm();
                OnDestroy();
            }
        });
        //赔偿结果
        LinearLayout resultLayout = (LinearLayout) mView.findViewById(R.id.pinfo_tv_result);
        for (int i = 0; i < baseBean.length; i++) {
            TextView tv = new TextView(mContext);
            String cpsMoney = baseBean[i].getString("cpsmoney");
            String ownother = baseBean[i].getString("ownother");
            String text = "";
            if (TextUtils.equals("0", ownother)) {
                text = "己方赔偿金额为" + cpsMoney + " 元；";
            } else if (TextUtils.equals("1", ownother)) {
                text = "对方赔偿金额为" + cpsMoney + " 元；";
            }
            tv.setText(CommontUtils.changeStrColor(text, cpsMoney, Color.RED));

            resultLayout.addView(tv);
        }
    }

    @Override
    public void refresh() {

    }

    @Override
    public void refreshByTime() {

    }

    @Override
    public void OnDestroy() {
        super.OnDestroy();
        mView = null;
    }
}
